package com.hnevc.xiaoming.worldcupapp2018.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.hnevc.xiaoming.worldcupapp2018.R;
import com.hnevc.xiaoming.worldcupapp2018.bean.AllBean;

import java.util.List;

/**
 * Created by Administrator on 2021/1/2.
 */
public class AllAdapter extends BaseAdapter {

    private List<AllBean.ItemBean> list;
    private Context context;

    public AllAdapter(List<AllBean.ItemBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.activity_all_xx, null);
        TextView teamId;
        ImageView teamPic;
        TextView teamName;
        teamId = (TextView) convertView.findViewById(R.id.teamId);
        teamPic = (ImageView) convertView.findViewById(R.id.teamPic);
        teamName = (TextView) convertView.findViewById(R.id.teamName);
        AllBean.ItemBean bean = list.get(position);
        teamId.setText(bean.getTeamId()+"");
        String url = bean.getTeamPic();
        int imgid = context.getResources().getIdentifier(url, "drawable", context.getPackageName());
        teamPic.setImageResource(imgid);
        teamName.setText(bean.getTeamName()+"");
        return convertView;
    }
}
